package com.boxing.dao;

import com.boxing.bean.Stu;

import java.util.List;

public class StuDaoImpl extends BaseDao implements StuDao{
    @Override
    public List<Stu> queryAllStu() {
        String sql = "select id, sno, name, sex, phone from t_stu";
        return queryList(sql, Stu.class);
    }

    @Override
    public boolean newStu(Stu stu) {
        String sql = "insert into t_stu set sno=?, name=?, sex=?, phone=?";
        return insertData(sql, stu.getSno(), stu.getName(), stu.getSex(), stu.getPhone()) >0;
    }

    @Override
    public boolean editStu(Stu stu) {
        String sql = "update t_stu set sno=?, name=?, sex=?, phone=? where id=?";
        return insertData(sql,  stu.getSno(), stu.getName(), stu.getSex(), stu.getPhone(), stu.getId())>0;
    }

    @Override
    public boolean deleteStu(Stu stu) {
        // (假删除)修改数据库中的一列, 标记该学生已被删除; 如果这样实现,则查看所有学生时,应当过滤已被删除的学生
        return false;
    }
}
